

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>ccqw.qtCompat &mdash; CCQW 0.1.1 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '0.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/sidebar.js"></script>
    <link rel="top" title="CCQW 0.1.1 documentation" href="../../index.html" />
    <link rel="up" title="Module code" href="../index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">CCQW 0.1.1 documentation</a> &raquo;</li>
          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for ccqw.qtCompat</h1><div class="highlight"><pre>
<span class="c"># -*- coding: utf-8 -*-</span>
<span class="sd">&quot;&quot;&quot; The main initialization of our PySide/PyQt4 Package.</span>

<span class="sd">  .. warning:: this module tries to</span>
<span class="sd">     import PySide if available, otherwise defaults to PyQt4 for the GUI.</span>
<span class="sd">     To change this behaviour set *_TRY_PYSIDE* to False.</span>


<span class="sd">  :Author:</span>
<span class="sd">    - 2009-2011 Nicola Creati</span>
<span class="sd">    - 2009-2011 Roberto Vidmar</span>

<span class="sd">  :Revision:  $Revision: 52 $</span>
<span class="sd">              $Date: 2012-11-12 10:07:15 +0100 (Mon, 12 Nov 2012) $</span>

<span class="sd">  :Copyright: 2011-2012</span>
<span class="sd">              Nicola Creati &lt;ncreati@inogs.it&gt;</span>
<span class="sd">              Roberto Vidmar &lt;rvidmar@inogs.it&gt;</span>

<span class="sd">  :License: MIT/X11 License (see :download:`license.txt</span>
<span class="sd">                               &lt;../../license.txt&gt;`)</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">with_statement</span>
<span class="kn">from</span> <span class="nn">__future__</span> <span class="kn">import</span> <span class="n">division</span>

<span class="n">_TRY_PYSIDE</span> <span class="o">=</span> <span class="bp">True</span>

<span class="k">try</span><span class="p">:</span>
  <span class="k">if</span> <span class="ow">not</span> <span class="n">_TRY_PYSIDE</span><span class="p">:</span>
    <span class="k">raise</span> <span class="ne">ImportError</span><span class="p">()</span>
  <span class="kn">import</span> <span class="nn">PySide.QtCore</span> <span class="kn">as</span> <span class="nn">_QtCore</span>
  <span class="kn">import</span> <span class="nn">PySide.QtGui</span> <span class="kn">as</span> <span class="nn">_QtGui</span>
  <span class="n">QtCore</span> <span class="o">=</span> <span class="n">_QtCore</span>
  <span class="n">QtGui</span> <span class="o">=</span> <span class="n">_QtGui</span>
  <span class="n">USES_PYSIDE</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
  <span class="kn">import</span> <span class="nn">sip</span>
  <span class="n">sip</span><span class="o">.</span><span class="n">setapi</span><span class="p">(</span><span class="s">&#39;QString&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
  <span class="n">sip</span><span class="o">.</span><span class="n">setapi</span><span class="p">(</span><span class="s">&#39;QVariant&#39;</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
  <span class="kn">import</span> <span class="nn">PyQt4.QtCore</span> <span class="kn">as</span> <span class="nn">_QtCore</span>
  <span class="kn">import</span> <span class="nn">PyQt4.QtGui</span> <span class="kn">as</span> <span class="nn">_QtGui</span>
  <span class="n">QtCore</span> <span class="o">=</span> <span class="n">_QtCore</span>
  <span class="n">QtGui</span> <span class="o">=</span> <span class="n">_QtGui</span>
  <span class="n">USES_PYSIDE</span> <span class="o">=</span> <span class="bp">False</span>

<span class="k">def</span> <span class="nf">_pyside_import_module</span><span class="p">(</span><span class="n">moduleName</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; The import for PySide</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="n">pyside</span> <span class="o">=</span> <span class="nb">__import__</span><span class="p">(</span><span class="s">&#39;PySide&#39;</span><span class="p">,</span> <span class="nb">globals</span><span class="p">(),</span> <span class="nb">locals</span><span class="p">(),</span> <span class="p">[</span><span class="n">moduleName</span><span class="p">],</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
  <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">pyside</span><span class="p">,</span> <span class="n">moduleName</span><span class="p">)</span>

<span class="k">def</span> <span class="nf">_pyqt4_import_module</span><span class="p">(</span><span class="n">moduleName</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; The import for PyQt4</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="n">pyside</span> <span class="o">=</span> <span class="nb">__import__</span><span class="p">(</span><span class="s">&#39;PyQt4&#39;</span><span class="p">,</span> <span class="nb">globals</span><span class="p">(),</span> <span class="nb">locals</span><span class="p">(),</span> <span class="p">[</span><span class="n">moduleName</span><span class="p">],</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
  <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">pyside</span><span class="p">,</span> <span class="n">moduleName</span><span class="p">)</span>

<span class="k">if</span> <span class="n">USES_PYSIDE</span><span class="p">:</span>
  <span class="n">import_module</span> <span class="o">=</span> <span class="n">_pyside_import_module</span>

  <span class="n">Signal</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">Signal</span>
  <span class="n">Slot</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">Slot</span>
  <span class="n">Property</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">Property</span>

  <span class="k">def</span> <span class="nf">getOpenFileName</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Wrap to PySide QtGui.QFileDialog.getOpenFileName</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">pn</span><span class="p">,</span> <span class="n">selectedFilter</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QFileDialog</span><span class="o">.</span><span class="n">getOpenFileName</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">pn</span>

  <span class="k">def</span> <span class="nf">getOpenFileNames</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Wrap to PySide QtGui.QFileDialog.getOpenFileNames</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">pn</span><span class="p">,</span> <span class="n">selectedFilter</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QFileDialog</span><span class="o">.</span><span class="n">getOpenFileNames</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">pn</span>

  <span class="k">def</span> <span class="nf">getSaveFileName</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Wrap to PySide QtGui.QFileDialog.getSaveFileName</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">pn</span><span class="p">,</span> <span class="n">selectedFilter</span> <span class="o">=</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QFileDialog</span><span class="o">.</span><span class="n">getSaveFileName</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">pn</span>
<span class="k">else</span><span class="p">:</span>
  <span class="n">import_module</span> <span class="o">=</span> <span class="n">_pyqt4_import_module</span>

  <span class="n">Signal</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">pyqtSignal</span>
  <span class="n">Slot</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">pyqtSlot</span>
  <span class="n">Property</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">pyqtProperty</span>

<div class="viewcode-block" id="getOpenFileName"><a class="viewcode-back" href="../../ccqw.html#ccqw.qtCompat.getOpenFileName">[docs]</a>  <span class="k">def</span> <span class="nf">getOpenFileName</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Wrap to PyQt4 QtGui.QFileDialog.getOpenFileName</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QFileDialog</span><span class="o">.</span><span class="n">getOpenFileName</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="getOpenFileNames"><a class="viewcode-back" href="../../ccqw.html#ccqw.qtCompat.getOpenFileNames">[docs]</a>  <span class="k">def</span> <span class="nf">getOpenFileNames</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Wrap to PyQt4 QtGui.QFileDialog.getOpenFileNames</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QFileDialog</span><span class="o">.</span><span class="n">getOpenFileNames</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="getSaveFileName"><a class="viewcode-back" href="../../ccqw.html#ccqw.qtCompat.getSaveFileName">[docs]</a>  <span class="k">def</span> <span class="nf">getSaveFileName</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Wrap to PyQt4 QtGui.QFileDialog.getSaveFileName</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="n">QtGui</span><span class="o">.</span><span class="n">QFileDialog</span><span class="o">.</span><span class="n">getSaveFileName</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
</div>
  <span class="n">QtCore</span><span class="o">.</span><span class="n">pyqtRemoveInputHook</span><span class="p">()</span>

<span class="n">Qt</span> <span class="o">=</span> <span class="n">QtCore</span><span class="o">.</span><span class="n">Qt</span>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/ogs.png" alt="Logo"/>
            </a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">CCQW 0.1.1 documentation</a> &raquo;</li>
          <li><a href="../index.html" >Module code</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Roberto Vidmar, Nicola Creati.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>